<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <el-tabs v-model="tabValue" type="card" @tab-click="changeTab()">
        <el-tab-pane :label="item.name" :name="item.id" v-for="item in typelist" :key="item.id"></el-tab-pane>
      </el-tabs>
      <el-tabs v-model="tabchildValue" type="card" v-if="Number(tabValue)==2||Number(tabValue)==3">
        <el-tab-pane :label="item.name" :name="item.id" v-for="item in typechildlist[tabValue]"
                     :key="item.id"></el-tab-pane>
      </el-tabs>
      <!--本体列表，数据 -->
<!--      <defaultTable v-if="Number(tabValue)==1" :tabchildValue="tabchildValue"></defaultTable>-->
      <archives :tabchildValue="tabchildValue" :tabValue="old_tabValue"></archives>
<!--      <official v-if="Number(tabValue)==3" :tabchildValue="tabchildValue"></official>-->
    </div>
  </div>
</template>

<script>
import drawerTask from '@/components/dialog/drawerTask.vue'
import taskDetailDialog from '@/components/dialog/taskDetailDialog.vue'
import {pagination, tableoption, hourTime} from '@/utils/util.js'
import detailPoupe from "./components/detailPoupe";
import api from '@/utils/api.js'
// table
import archives from "./components/table/archives";
import defaultTable from "./components/table/defaultTable";
import official from "./components/table/official";

export default {
  components: {
    drawerTask,
    taskDetailDialog,
    detailPoupe,
    archives,
    defaultTable,
    official
  },
  data() {
    return {
      dialogDrawerVisible: false, // 右侧滑窗状态
      arryList: [], // 页面数据列表
      taskDetailvisible: false, // 任务
      // 搜索设置
      searchWord: '', // 搜索名称
      // 设置table样式
      tableStyle: tableoption,
      // 设置table页面分页所需
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      editBox: null,
      clickStatus: null,
      taskId: null,
      editForm: {
        name: '',
        is_finish: '',
        p: '',
        type: ''
      },
      timeList: [
        {
          name: '全部',
          id: ''
        },
        {
          name: '最近一周',
          id: 1
        },
        {
          name: '最近一月',
          id: 2
        }
      ],
      sectionList: [
        {
          name: '全部',
          id: ''
        },
        {
          name: '执行中',
          id: 0
        },
        {
          name: '完成',
          id: 1
        }
      ],
      userInfomation: null,
      tabValue: '1',
      old_tabValue: '1',
      typelist: [
        {
          id: '1',
          name: '普通任务'
        },
        {
          id: '2',
          name: '档案任务'
        },
        {
          id: '3',
          name: '公文任务'
        }
      ],
      tabchildValue: '1',
      typechildlist: {
        1: [
          {
            id: '1',
            name: '我的任务'
          },
          {
            id: '2',
            name: '我的发布'
          }
        ],
        2: [
          {
            id: '1',
            name: '我的任务'
          },
          {
            id: '2',
            name: '我的发布'
          },
          {
            id: '3',
            name: '审阅任务'
          }
        ],
        3: [
          {
            id: '1',
            name: '我的任务'
          },
          {
            id: '2',
            name: '我的发布'
          },
          {
            id: '3',
            name: '抄送任务'
          }
        ],
      }
    }
  },
  created() {
  },
  methods: {
    changeTab(){
      if(this.tabValue !== this.old_tabValue){
        console.log(this.tabValue,this.old_tabValue)
        this.tabchildValue= '1'
        this.old_tabValue = this.tabValue
      }
    },
    // 刷新页面
    refreshFn() {
      this.InitFn()
    },
    // 设置默认选中
    checked(option) {
      if (option === 'first' && JSON.stringify(this.applyBookBox) !== '{}') {
        this.applyBookBox = {}
        this.$refs.table.clearSelection()
      }
      for (let i = 0; i < this.userList.length; i++) {
        if (this.applyBookBox[this.userList[i].id]) {
          this.$refs.table.toggleRowSelection(this.userList[i], true)
        }
      }
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    // 刷新详情信息
    getUser() {
      this.taskDetail(this.editBox, 'refreshFn')
    },
    // 弹窗
    checkTask() {

    },
    handleDetel(index) {
      this.$confirm('确认永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.detelRespon(index)
      }).catch(() => {
      })
    },
    detelRespon(index) {
      this.$post(api.task_delete, {id: this.arryList[index].id}).then((response) => {
        if (response.code === 0) {
          this.arryList.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    }
  },
  mounted() {
  }
}
</script>

<style lang="scss">
.evaluateBox {
  background: #eee;
  margin-top: 5px;
  border-radius: 4px;
  padding: 5px;
}

.lookLsit {
  cursor: pointer;
}

.lookLsit:hover {
  text-decoration: underline;
}

#tablebox {
  display: flex;
  flex-direction: column;
}

.el-table {
  color: #000;
}

.right-box .container .main .content-container .input-val-box .input-top {
  width: 250px;
}

.contentTitle {
  line-height: 1.3;
  max-height: 300px;
  overflow-y: auto;
  padding-top: 11px;

  img {
    width: 100%;
    margin: 5px 0
  }
}
</style>
